<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/12
 * Time: 13:40
// */
$xml=<<<XML

<xml>
<ToUserName><![CDATA[toUser]]></ToUserName>
        <FromUserName><![CDATA[FromUser]]></FromUserName>
        <CreateTime>123456789</CreateTime>
        <MsgType><![CDATA[event]]></MsgType>
        <Event><![CDATA[CLICK]]></Event>
        <EventKey><![CDATA[EVENTKEY]]></EventKey>
</xml>

<!--<ToUserName><![CDATA[test]]></ToUserName>-->

<!--<FromUserName><![CDATA[o6_bmjrPTlm6_2sgVt7hMZOPfL2M]]></FromUserName>-->

<!--<CreateTime>1348831860</CreateTime>-->

<!--<MsgType><![CDATA[text]]></MsgType>-->

<!--<Content><![CDATA[this is a test]]></Content>-->

<!--<MsgId>1234567890123456</MsgId>-->

<!--</xml>-->

 
        



XML;

$data=simplexml_load_string($xml,'SimpleXmlElement',LIBXML_NOCDATA);
var_dump($data);

//print_r($data->MsgType.'');//直接与一个空字符连接，将SimpleElement对象转化为字符串
////或者使用string进行强转化
//var_dump((string)$data->MsgType);
//$a=var_dump((string)$data->MsgType);
print_r($data->MsgType."<br>".$data->FromUserName);





//$xml1=<<<XML
//<xml>
//1233
//</xml>
//
//
//
//XML;


